//
//  MBProgressHUD+TXExtension.m
//  TXKit
//
//  Created by YM on 17/3/17.
//  Copyright © 2017年 Tincent. All rights reserved.
//

#import "MBProgressHUD+TXExtension.h"

#define kProgressImage                [UIImage imageNamed:@"refresh_img_down"]

@implementation MBProgressHUD (TXExtension)

+ (instancetype)TXShowHUDInView:(UIView *)inView {
    
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:inView animated:YES];
    
    hud.mode = MBProgressHUDModeCustomView;
    
    //自定义动画
    UIImage *image = kProgressImage;
    UIImageView *imgView = [[UIImageView alloc] initWithImage:image];
    CABasicAnimation *anima = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
    anima.toValue = @(M_PI*2);
    anima.duration = 1.0f;
    anima.repeatCount = 1000;
    [imgView.layer addAnimation:anima forKey:nil];
    hud.customView = imgView;
    
    //背景图颜色
    hud.bezelView.color = [UIColor colorWithWhite:0.0 alpha:0.8];
    //文字颜色
    hud.contentColor = [UIColor whiteColor];
    //设置大小
    hud.minSize = CGSizeMake(75, 70);
    //动画类型
    hud.animationType = MBProgressHUDAnimationFade;
    
    return hud;
}

+ (void)TXHideHUDForView:(UIView *)inView {
    
    [MBProgressHUD hideHUDForView:inView animated:YES];
}

@end
